

<template>
<div style="padding-top:100px; padding-left: 40% ">
  <el-form :model="form" label-width="auto" style="max-width: 600px">
    <el-form-item label="用户名">
      <el-input v-model="form.username" />
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="form.pwd" type="password"/>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="login">登录</el-button>

    </el-form-item>
  </el-form>
</div>

</template>

<style scoped>

</style>

<script setup lang="ts">
import { reactive } from 'vue'

// do not use same name with ref
const form = reactive({
  username: '',
  pwd: '',

})
import axios from "axios";

import router from "@/router";
  const login = () =>
      axios.get('http://127.0.0.1:8001/demo/delete'+'?username='+form.username +'&pwd=' +form.pwd).then(res=>{

        if(res.data.code === 200){
          console.log(res.data.data)
          router.push('/index')
        }
        else {
          console.log(res.data.data)
          router.push('/')
        }

      })



</script>